package com.git.hui.yinshua.biz.pay.dao.mapper;

import com.git.hui.yinshua.biz.pay.dao.entity.OrderPaymentEntity;
import com.git.hui.yinshua.biz.pay.dao.entity.OrderRefundEntity;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * 支付处理类
 *
 * @author YiHui
 * @date 2024/9/9
 */
public interface OrderPaymentMapper {


    /**
     * 根据支付单id查询
     *
     * @param payId
     * @return
     */
    OrderPaymentEntity queryByPayId(@Param("payId") Long payId);

    /**
     * 根据订单查询支付单
     *
     * @param orderId 订单
     * @return
     */
    OrderPaymentEntity queryByOrderId(@Param("orderId") Long orderId);

    /**
     * 批量查询
     *
     * @param orderIds
     * @return
     */
    List<OrderPaymentEntity> batchQueryByOrderId(@Param("orderIds") Collection<Long> orderIds);

    /**
     * 根据外部单号查询支付单
     *
     * @param uuid
     * @return
     */
    OrderPaymentEntity queryByUuidForUpdate(@Param("uuid") String uuid);


    /**
     * 保存支付单
     *
     * @param payment
     * @return
     */
    Long savePayment(@Param("payment") OrderPaymentEntity payment);


    /**
     * 更新预支付信息
     *
     * @param payId
     * @param prePayId
     * @param expireTime
     * @return
     */
    Integer updatePrePayId(@Param("id") Long payId, @Param("prePayId") String prePayId, @Param("expireTime") Long expireTime);

    /**
     * 支付单更新
     *
     * @param orderPayment
     * @return
     */
    Integer updatePayment(OrderPaymentEntity orderPayment);

    Integer updatePaying(@Param("orderId") Long orderId);

    /**
     * 保存退款申请
     *
     * @param refund
     * @return
     */
    Integer saveRefund(@Param("refund") OrderRefundEntity refund);


    /**
     * 更新退款信息
     *
     * @param refund
     * @return
     */
    Integer updateRefundInfo(OrderRefundEntity refund);

    OrderRefundEntity queryRefundByUuidForUpdate(@Param("uuid") String uuid);

    List<OrderRefundEntity> batchQueryRefundByOrderId(@Param("orderIds") Collection<Long> orderIds);
}
